Frn: Anders Tiberg <anders.tiberg@telia.com>
Till: <filearchive@ticalc.org>
mne: PrimeC
Datum:  den 8 januari 2001 22:57



       Program PrimeC v2.72 written by Anders Tiberg.


This program based upon the same two ideas for program code by
Charles J. Srstka that I used in PrList, runs in about 20% of the
time for the ordinary primefactor program.1: The number is divided
by a whole list of potential primefactors.This way many operations
can be carried out with the built in list functions, in the same ti-
me as only one in the ordinary program.2: The TI-83 can't handle the
command 1+dimL unless the list specified has at least one number.
While working with PrList,Charles suggested that I'd use {0}->L1 and
then P->L1((L1(1)>0)+dimL(L1)) thus overwriting the first element in
the list.This is an idea that I like very much.Suppose you have an ex-
pression wich calculates the value for I and that value is to be rai-
sed by N every time A is bigger than thirty. Most of us would write
:If A>30:I+N->I, after the expression, when all you have to do is
just add +N(A>30) to it(wich is also many times faster).

Some words about the program:Version 2.72 is optimized for bigger
numbers and is an improvement over v2.0(wich has a bug) and earlier
versions.The numbers in the list now go from 11 onto 211,without any
factor 2,3,5 or 7,as apart from version 1.10 that used the primes
from 7 onto 31.
(Since then I discovered that I was not the first to have this idea.
In the TI-83 Basic Math directory is the program ABIGSIV by Rob Gaebler
that uses the same list. Also the program PRIME6 in the TI-85 Basic Math
directory)
The numbers are in list LN,wich is counted up by 210 each time.This
version,runs 30% faster,for a large primenumber,than v1.10.Below is
a transcript of the program.It takes about 1 minute and 5 sec.to ve-
rify that 999,999,937 is a primenumber.
After consulting Rob several times this is it:


 PrCinst
:{11}->LN
:For(P,13,211,2
:If min(fPart(P/{3,5,7}
:P->LN(1+dim(LN
:End

 PrimeC v2.72
:ClrHome
:{0}->L1
:Promt X
:X->Z
:0->F
:4->I
:2->P
:While not(fPart(X/2
:Lbl 1
:P->L1((X<Z)+dim(L1
:X/P->X
:Disp P
:End
:For(P,P+(P>2)+1,19,2
:While not(fPart(X/P
:Goto 1
:End
:End
:F->G
:For(F,F,\/(X)-P(P^2>X),210    
:If not(min(fPart(X/(LN+F
:Then
:For(I,I(F=G)+1,48
:F+LN(I->P
:While not(fPart(X/P
:Goto 1
:End
:End
:End
:End
:If X>1
:X->L1((X<Z)+dim(L1
:ClrHome
:Disp "",Z,"",dim(L1
:L1


When X is promted you enter a positive integer.The factors are put in
list L1 and then displayed as the program goes forth.
When X=144 it looks like this:

X=?144
                2
                2
                2
                2
                3
                3
 
the window is then cleared and the result is presented:
 
              
              144
       
                6
    {2 2 2 2 3 3}

 
       
            Any questions or input mailto: anders.tiberg@telia.com  
 
                    
 